<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>历史版本</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=10,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
    <link rel="stylesheet" type="text/css" href="/lib/layui/layui/css/layui.css"/>
    <script type="text/javascript" src="/lib/layui/layui/layui.js"></script>
    <script type="text/javascript" src="/lib/layui/layui/layui.all.js"></script>
    <script type="text/javascript" src="/js/news/jquery-1.9.1.js"></script>
    <script type="text/javascript" src="/lib/jquery-2.1.4.min.js"></script>
    <script src="../js/sys/citys.js" type="text/javascript" charset="utf-8"></script>
    <script src="/js/base/base.js" type="text/javascript" charset="utf-8"></script>
    <script src="/js/sys/citys.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript" src="/lib/layui/layui/global.js"></script>
</head>
<style>


    .mbox {
        padding: 8px;
    }

    .items {
        background-color: #f2f2f2;
        text-align: center;
        height: 30px;
        line-height: 30px;
    }

    .layui-form-item {
        margin-bottom: 5px;
    }

    .inpWhit {
        width: 300px;
    }

    /*下拉按钮*/
    .dropbtn {
        text-align: left;
        background-color: #009688;
        color: white;
        font-size: 12px;
        border: none;
        cursor: pointer;
        height: 30px;
        width: 90px;
    }

    /* 容器 <div> - 需要定位下拉内容 */
    .dropdown {
        position: relative;
        display: inline-block;
    }

    /* 下拉内容 (默认隐藏) */
    .dropdown-content {
        margin-left: 0px;
        display: none;
        position: absolute;
        top: 32px;
        background-color: #fff;
        min-width: 115px;
        text-align: center;
        line-height: 36px;
        padding-top: 10px;
        box-shadow: 0px 8px 12px 0px rgba(0, 0, 0, 0.2);
        z-index: 999999999;
    }

    .licon {
        display: inline-block;
        width: 0;
        height: 0;
        border-style: dashed;
        border-color: transparent;
        position: absolute;
        right: 6px;
        top: 52%;
        margin-top: -3px;
        cursor: pointer;
        border-width: 6px;
        border-top-color: #fff;
        border-top-style: solid;
        transition: all .3s;
        -webkit-transition: all .3s;
    }

    * {
        font-family: "Microsoft Yahei" !important;
    }

    b {
        color: red;
    }

    /* 下拉菜单的链接 */
    .dropdown-content a {
        color: black;
        /*padding: 12px 16px;*/
        text-decoration: none;
        display: block;
    }

    /*!* 在鼠标移上去后显示下拉菜单 *!*/
    .icon-on {
        margin-top: -9px;
        -webkit-transform: rotate(180deg);
        transform: rotate(180deg);
    }

    .layui-table {
        width: 100% !important;
    }
    .bg{
        background: #f2f2f2;
    }

    nav div{
        float: left !important;
        margin: 15px;
    }
    nav{
        height: 50px;
        border-bottom: 1px solid #cfdbe2;
        background-color: #fafbfc;
        border-radius: 0;
    }
    .time{
        width: 90px;
        margin-left: 0px;
        display: inline;
    }
    .input{
        margin-left: 130px;
    }
    .layui-table-body{overflow-x: hidden;}

    /*.laytable-cell-1-0-0 {*/
    /*    width: 86px;*/
    /*}*/

</style>
<body>

<div class="mbox">
    <form class="layui-form">
        <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
            <ul class="layui-tab-title">
                <li class="layui-this">历史版本</li>

            </ul>

            <div class="layui-tab-content" style="height: 100px;">
                <%--<input id="inventoryId" name="inventoryId" type="hidden" value="${financialCompanyDO.inventoryId}"/>--%>
                <div class="layui-tab-item layui-show" >
                    <%--内容1--%>
                    <div class="layui-form-item" style="display: none">
                        <div class="layui-input-inline">
                            <input type="text" id="inventoryIds" required lay-verify="required" placeholder="" autocomplete="off" class="layui-input"  value="${inventoryId}">
                            <input type="text" id="types" required lay-verify="required" placeholder="" autocomplete="off" class="layui-input"  value="${types}">

                        </div>
                    </div>
                    <div>
                        <table id="demo" lay-filter="test"></table>
                    </div>

                </div>

            </div>

        </div>
        <div>
            <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
            </div>
        </div>
    </form>

</div>
</div>

<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="edit">查看详情</a>
</script>

<script type="text/javascript">
    function getQueryString (name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return unescape(r[2]);
        return null;
    }

    var instId=getQueryString('instId');
    var table,form,laydate,element,layedit;

    $(function (){
        layui.use(['table', 'form', 'laydate','element','layedit'], function () {
            table = layui.table,
                form = layui.form,
                laydate = layui.laydate,
                element = layui.element,
                layedit = layui.layedit;

            table.render({
                elem: '#demo'
                , url: '/InstitutionContent/findContentHistory' //数据接口
                ,where:{
                    instType:1,
                    instId:instId
                }
                , id: 'tableOne'
                ,cols:[[
                    {field:'instName',title:'名称',align:'center',event:'title',templet:function (d) {
                            return '<a href="javascript:;" style="text-decoration:underline;color:blue">'+d.instName+'</a>'
                        }}
                    ,{field:'instNumber',title:'编号',align:'center'}
                    ,{field:'instStatus',title:'使用状态',align:'center',templet:function (d) {
                            if (d.instStatus==1){
                                return "生效"
                            }else{
                                return "停用"
                            }
                        }}
                    ,{field:'approveStatus',title:'审核状态',align:'center',templet:function (d) {
                            if (d.approveStatus==0){
                                return "待审批"
                            }else if (d.approveStatus==1){
                                return "已批准"
                            }else if(d.approveStatus==2){
                                return "未批准"
                            }else if(d.approveStatus==3){
                                return "未提交"
                            }
                        }},
                    {field:'version',title:'当前版本',align:'center'},
                    {field:'editContent',title:'修编说明',align:'center'},
                    {title:'操作',align:'center',toolbar:'#barDemo',width:300}
                ]]
                ,response: {
                    statusName: 'flag',  //规定数据状态的字段名称，默认：code
                    statusCode: true,   //规定成功的状态码，默认：0
                    dataName: 'obj',    //规定数据列表的字段名称，默认：data
                    countName: 'totleNum'
                }

            });

            //监听工具条
            table.on('tool(test)', function (obj) {
                var data = obj.data;
                var layEvent = obj.event;
                var tr = obj.tr;
                if (layEvent === 'edit') {
                    edit(data);
                }
                if (layEvent=="title"){
                    if(data.instType == 1){
                        layer.open({
                            type: 2,
                            isOutAnim:true,
                            maxmin:true,
                            title:'制度详情',
                            area:['100%','100%'],
                            btnAlign: 'c',
                            btn: ['返回'],
                            content:'/institution/selectInstitution?instId='+data.instId
                            ,yes: function(index){
                                layer.close(index);
                            }
                        });
                    }

                }

            });
        });
    })

    function edit(data) {
        layer.open({
            type: 1 //Page层类型
            , area: ['700px', '500px']
            , title: '详情'
            , content: '<div class="layui-form">' +
                '<form id="ajaxforms" action="/customer/addWorkbench"><div><div class="items">历史版本详情</div><div style="margin-top:10px" >\n' +

                '            <div class="layui-form-item" style="width: 320px;">\n' +
                '                <label class="layui-form-label">制度名称:</label>\n' +
                '                <div class="layui-input-block">\n' +
                '                    <input id="chargeTypeValue"  type="text" name="chargeTypeValue" required lay-verify="required" placeholder=""\n' +
                '                           autocomplete="off" class="layui-input" style="border: 0">\n' +
                '                </div>\n' +
                '            </div>\n' +
                '            <div class="layui-form-item" style="width: 320px;">\n' +
                '                <label class="layui-form-label">制度编号:</label>\n' +
                '                <div class="layui-input-block">\n' +
                '                    <input id="chargeCost" type="text" name="chargeCost" required lay-verify="required" placeholder=""\n' +
                '                           autocomplete="off" class="layui-input" style="border: 0">\n' +
                '                </div>\n' +
                '            </div>\n' +

                '            <div class="layui-form-item" style="width: 320px;">\n' +
                '                <label class="layui-form-label">使用状态:</label>\n' +
                '                <div class="layui-input-block">\n' +
                '                    <input id="chargeUndertaker" type="text" name="chargeUndertaker" required lay-verify="required" placeholder=""\n' +
                '                           autocomplete="off" class="layui-input" style="border: 0">\n' +
                '                </div>\n' +
                '            </div>\n' +

                '        </div></div>' +
                '<div>' +
                '<div style="margin-top:10px">' +
                '            <div class="layui-form-item" style="width: 320px;">\n' +
                '                <label class="layui-form-label">审核状态:</label>\n' +
                '                <div class="layui-input-block">\n' +
                '                    <input id="userName" type="text" name="userName" required lay-verify="required" placeholder=""\n' +
                '                           autocomplete="off" class="layui-input" style="border: 0">\n' +
                '                </div>\n' +
                '            </div>\n' +
                '   <div class="layui-form-item" style="width: 320px;">\n' +
                ' <input type="radio" name="sex" checked="checked"  id="male" title="男" value="1"/>\n' +
                '  <input type="radio" name="sex"  id="woman" title="女" value="2"/></div>' +
                '</div>' +
                '<div >' +
                '  <div class="layui-form-item" style="width: 320px;">\n' +
                '    <label class="layui-form-label">当前版本:</label>\n' +
                '    <div class="layui-input-block">\n' +
                '      <input id="assetsId" type="text" name="department" required  lay-verify="required" placeholder="" autocomplete="off" class="layui-input" style="border: 0">\n' +
                '    </div>\n' +
                '  </div> ' +
                //    修编说明
                '  <div class="layui-form-item" style="width: 320px;">\n' +
                '    <label class="layui-form-label">修编说明:</label>\n' +
                '    <div class="layui-input-block">\n' +
                '      <div id="xiubian" type="text" name="department" required  lay-verify="required" placeholder="" autocomplete="off" class="layui-input" style="border: 0;width: 500px;position: relative;top: 10px"></div>\n' +
                '    </div>\n' +
                '  </div> ' +
                ' </div>' +
                '<div >' +
                '</div>' +
                '</div>' +
                '</form></div>'
            ,btn:['返回']
            , success: function (res) {

                var approveStatus = ''
                if (data.approveStatus==0){
                    approveStatus=  "待审批"
                }else if (data.approveStatus==1){
                    approveStatus=  "已批准"
                }else if(data.approveStatus==2){
                    approveStatus=  "未批准"
                }else if(data.approveStatus==3){
                    approveStatus=  "未提交"
                }


                var instStatus = ''
                if (data.instStatus==1){
                    instStatus =  "生效"
                }else{
                    instStatus =  "停用"
                }

                $("#paymentDate").val(data.fileNum);
                $("#userName").val(approveStatus);
                $("#chargeTypeValue").val(data.instName);
                $("#chargeUndertaker").val(instStatus);
                $("#chargeCost").val(data.instNumber);
                $("#assetsId").val(data.version);
                //修编说明
                $("#xiubian").html(data.editContent);

            }
            , yes: function (index) {
                layer.close(index)
            }
        });
    }

</script>
</body>
</html>



